<?php

namespace app\admin\model\orders;

use app\admin\model\orders\Shopping as ShoppintCar;
use think\Model;
use think\Request;

class Shopping extends Model
{
    // 表名
    protected $name = 'shopping_cart';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    /**
     * 获取购物车数量
     * @return int|string|\think\response\Json
     * @throws \think\Exception
     */
    public static function shoppingCart($agentid,$type = 2)
    {
        $count = Shopping::where(['agentid'=>$agentid,'sorter'=>$type])->count();
        return $count;
    }

}
